package com.ys.erp.entity.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ys.erp.entity.data.bean.EventLog;
import com.ys.erp.entity.mapper.EventLogMapper;
import com.ys.erp.entity.service.IEventLogService;
import com.ys.erp.framework.bean.dto.EmpDTO;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

/**
 * @author lwj
 * @date 2025/5/28
 */
    
@Service
public class IEventLogServiceImpl extends ServiceImpl<EventLogMapper, EventLog> implements IEventLogService {

    @Override
    @Async
    public void insertEvent(EmpDTO emp, String remark, Long relevanceId, Integer isImportant, String reqParam) {
        try {
            EventLog eventLog = new EventLog();
            eventLog.setEmpId(emp.getId());
            eventLog.setEmpName(emp.getRealName());
            eventLog.setRelevanceId(relevanceId);
            eventLog.setEventRemark(remark);
            eventLog.setTime(LocalDateTime.now());
            eventLog.setIsImportant(isImportant);
            eventLog.setShopCode(emp.getShopCode());
            eventLog.setReqParam(reqParam);
            this.save(eventLog);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
